<?php
if(!defined('DIR_INIT'))exit();
$view_type = $x->get_view_type($ext);
if($view_type!='pdf') sysmsg('不支持的文件格式');

$path = $_GET['path'] ?? '';
if(!file_exists($path)) {
    die('文件不存在');
}
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . basename($path) . '"');
header('Content-Length: ' . filesize($path));
$pdf_read = readfile($path);
$pdf_read = htmlspecialchars($pdf_read);
?><!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8" />
    <title>pdf查看器</title>
</head>
<body><style>pre {
        color: white;padding:1em;
        background-color: #111;
        white-space: pre-wrap;
        word-wrap: break-word;
    }</style>
<pre id="code">
<?php echo $pdf_read; ?>
</pre>
<script src="/app/lib/pre.js"></script>
<script>
    let p=document.getElementById("code").innerHTML;
    document.getElementById("code").innerHTML=pre(p)
</script>
</body>
</html>